package com.bracketbird.client.service.rtc;

import com.bracketbird.client.gui.club.tournament.rtc.*;
import com.bracketbird.client.model.*;
import com.bracketbird.client.model.tournament.*;
import com.bracketbird.clientcore.model.*;

/**
 *
 */
public class RTCEventFac {

    
    
    private static Tournament getTournament(){
        return RTC.getInstance().getTournament();
    }

 

    //TEAM EVENTS

    public static RTCEvent createAddTeamEvent(PlayingTeam team) {
        RTCEvent e = new RTCEvent(RTCEventType.addTeam, getTournament());
        e.setPlayingTeamVO(team.createVO());
        e.setModel(team);
        return e;
    }

    public static RTCEvent createDeleteTeamEvent(PlayingTeam team) {
        RTCEvent e = new RTCEvent(RTCEventType.deleteTeam, getTournament());
        e.setModel(team);
        e.setModelId(team.getId());
        return e;
    }


    public static RTCEvent createUpdateTeamEvent(PlayingTeam team, PlayingTeamVO vo) {
        RTCEvent e = new RTCEvent(RTCEventType.updateTeam, getTournament());
        e.setModel(team);
        e.setModelId(team.getId());
        e.setPlayingTeamVO(vo);
        return e;
    }


    //LEVEL EVENTS
    public static RTCEvent createAddLevelEvent(TournamentLevel tl) {
        RTCEvent e = new RTCEvent(RTCEventType.addLevel, getTournament());

        e.setTournamentLevelVO(tl.createVO());
        e.setModel(tl);
        return e;
    }

    public static RTCEvent createDeleteLevelEvent(TournamentLevel tl) {
        RTCEvent e = new RTCEvent(RTCEventType.deleteLevel, getTournament());
        e.setModel(tl);
        e.setModelId(tl.getId());
        return e;
    }

    public static RTCEvent createUpdateLevelEvent(TournamentLevel tl, LevelSettings ls){
        RTCEvent e = new RTCEvent(RTCEventType.updateLevel, getTournament());
        e.setModel(tl);
        e.setModelId(tl.getId());
        e.setTournamentLevelVO(ls.createVO(tl));
        return e;
    }


    //MATCHES EVENTS
    public static RTCEvent createLayoutMatchesEvent(TournamentLevel tl) {
        RTCEvent e = new RTCEvent(RTCEventType.layoutMatches, getTournament());
        e.setModel(tl);
        e.setModelId(tl.getId());
        return e;
    }


    public static RTCEvent createUpdateMatchEvent(TournamentLevel level, MatchVO vo) {
        RTCEvent e = new RTCEvent(RTCEventType.updateMatch, getTournament());
        e.setModelId(level.getId());
        e.setMatchVO(vo);
        return e;
    }


    public static RTCEvent createLevelFinishedEvent(TournamentLevel level, LevelFinishedVO vo) {
        RTCEvent e = new RTCEvent(RTCEventType.finishedLevel, getTournament());
        e.setModelId(level.getId());
        e.setLevelFinishedVO(vo);
        return e;
    }
}
